<?php

require('../init.php');

$act = safeCheck($_GET['act'], 0);
switch($act){
    case 'add':
        $qqnum=safeCheck($_POST['qqnum'],0);
        $groupnum=safeCheck($_POST['groupnum'],0);
        $kicktime=safeCheck($_POST['kicktime'],0);
        $ad=safeCheck($_POST['desc'],0);
        try {
            echo QQData::add($qqnum, $groupnum, $kicktime,$ad);
        }catch (MyException $e){
            echo $e->jsonMsg();
        }
        break;
    case "alldata":
        $page_index=safeCheck($_POST['page_index'],0);
        $page_size=safeCheck($_POST['page_size'],0);
        try {
            echo QQData::alldata($page_index,$page_size);
        }catch (MyException $e){
            echo $e->jsonMsg();
        }
        break;
    case "del":
        $ids=$_POST['ids'];
        try {
            $num=0;
            foreach ($ids as $id){
                $id=safeCheck($id,0);
                $num+=QQData::deletebyid($id);
            }
            $msg="总共删除了 $num 条记录";
            echo action_msg($msg,1);
        }catch (MyException $e){
            echo $e->jsonMsg();
        }
        break;
    case "filtdata":
        $page_index=safeCheck($_POST['page_index'],0);
        $page_size=safeCheck($_POST['page_size'],0);
        $qq=safeCheck($_POST['qq'],0);
        $groupnum=safeCheck($_POST['groupnum'],0);
        $start=safeCheck($_POST['start'],0);
        $end=safeCheck($_POST['end'],0);
        $param=array(
            'qq'=>$qq,
            'groupnum'=>$groupnum,
            'start'=>$start,
            'end'=>$end
        );
        try {
            echo QQData::filtdata($page_index,$page_size,$param);
        }catch (MyException $e){
            echo $e->jsonMsg();
        }


        break;
    default:
        echo action_msg("404 参数不存在",404);
        break;
}

